/**
 * 可视化展示
 */
Ext.define('Module.sjfx.KshzsFusion', {
	extend : 'Ext.panel.Panel',
	layout: 'border',
	border: true,
	initComponent : function() {
		var me = this;
		me.on("boxready",function(){
			me.updatePanel(null);
		});
		
		
	  /**
	   * 今日完成数前十排名
	   */
	  var todayWcShu=Ext.create('Sh.ux.FusionChartPanel', {
			title:'今日任务前二十排名',
			columnWidth:1,
			height:400,
		    swf: 'javascript/fs/chart/Column3D.swf',
		    dataurl: 'sjfx/KshzsAction/getTodayWcShu.do'
		});
		
		/**
		 * 任务总数
		 */
		var todayWc = me.completionChart('今日完成率',1,'');
		var weekWc = me.completionChart('本周完成率',2,'');
		var monthWc = me.completionChart('本月完成率',3,'');
		

		
		var panel =Ext.create('Ext.panel.Panel',{
			autoScroll: true,
			layout:'column',
			region: 'center',
			bodyStyle:{
				backgroundColor:'#DBF2EF'
			},
			defaults: {
				height: 210,
				border:true,
				'margin':'5 0 0 7',
				columnWidth:1/4
			},
			items:[{
				id:'panel_Kshzs_id',
				bodyStyle:{
					backgroundColor:'#EFF2F5'
				},
//				title:"输电专业",
				tpl:new Ext.Template([
                  '<div style="float: left;margin-left: 6%; width: 100%;font-style:normal;font-size: 12;">'+
	              		'<div style="width: 20%;float: left;margin-top: 5%; ">                                                                     '+
	            		'</div>                                                                                                     '+
	            	  '<div style="margin-top: 15%;float: left;width: 90%;line-height:2.7;">'+
	            		'<div style="width: 50%;float: left;">                                                                      '+
	            		'	<ul style="list-style-type: none;padding: 0;">                                          '+
	            		'		<li>今日任务总数：{zTodayCount}</li>                                                                              '+
	            		'		<li>本周任务总数：{zWeekCount}</li>                                                                              '+
	            		'		<li>本月任务总数：{zMonthCount}</li>                                                                              '+
	            		'	</ul>                                                                                                   '+
	            		'</div>                                                                                                     '+
	            		'<div style="width: 50%;float: left;">                                                     '+
	            		'	<ul style="list-style-type: none;padding: 0;">                                                          '+
	            		'		<li>今日完成总数：{todayCountOk}</li>                                                                              '+
	            		'		<li>本周完成总数：{weekCountOk}</li>                                                                              '+
	            		'		<li>本月完成总数：{monthCountOk}</li>																				'+
	            		'	</ul>				'+
	            		'</div>'+
            	'</div>'	
            		])
			},todayWc,weekWc,monthWc,todayWcShu	
		   ]
		});
		
		var menutree =  Ext.create('Ext.tree.Panel',{
			rootVisible: false,
			border: true,
			singleExpand: true,
			region: 'west',
			width: 190,
			id:"kshzs_tree_id",
			expanded: true, 
			store: Ext.create('Ext.data.TreeStore', {
		        proxy: {
		            type: 'ajax',
		            url: 'sjfx/KshzsAction/getVtree.do'
		        },
		        root: {
		        	expanded: true,  
		            id: '0'
		        }
		    }),
			listeners:{
				select:function(r,c){
					me.updatePanel(c.raw.pid);
					todayWc.update({
						params:{
							variable:1,
							jcBdzId: c.raw.pid
						}
					});
					weekWc.update({
						params:{
							variable:2,
							jcBdzId: c.raw.pid
						}
					});
					monthWc.update({
						params:{
							variable:3,
							jcBdzId: c.raw.pid
						}
					});
					chartZhuZhuangStore.load({
						params:{
							jcBdzId: c.raw.pid
						}
					});
				}
			}
		});


		me.items = [menutree,panel];

		me.callParent();
	},
	updatePanel:function(jcBdzId){
		 Ext.Ajax.request({
             url: 'sjfx/KshzsAction/getCountByWorksy.do',
             params:{
            	 jcBdzId:jcBdzId
             },
             success: function (response, options) {
            	 var data = Ext.decode(response.responseText);
         	     Ext.getCmp("panel_Kshzs_id").update(data);
             }
         });
	},
	completionChart : function(title,variable,jcBdzId){
		return Ext.create('Sh.ux.FusionChartPanel', {
				title:title,
			    swf: 'javascript/fs/chart/AngularGauge.swf',
			    dataurl: 'sjfx/KshzsAction/getCountByWorkAndPatrol.do',
			    params: {
			    	variable:variable,
		    		jcBdzId:jcBdzId
		    	}
			});
	}
});
